import {Toast} from 'antd-mobile'
import React from 'react'
import {font} from "./Metrics";


export function show_loading(content) {
  content = content || '加载中...'
  Toast.loading(content, 9000, () => {
    console.log('Load complete !!!');
  });
}

export function hidden_loading() {
  Toast.hide();
}

export function show_info(image_path,content) {
  Toast.info(<CustomeHudContent image_path={image_path} content={content}/>,2);
}

export function show_success(content) {
  content = content||'加载成功'
  Toast.success(content, 2);
}

export function show_error(content) {
  content = content||'加载失败'
  Toast.fail(content, 2);
}

const CustomeHudContent = ({image_path,content}) => (
  <div style={{display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',paddingLeft:font(38),paddingRight:font(38),paddingBottom:font(10),paddingTop:font(30)}}>
    <img src={image_path} style={{width:font(70),height:font(70)}}/>
    <span style={{textAlign:'center',paddingTop:10,fontSize:font(30)}}>{content}</span>
  </div>
)
